Fix: Bug pada Modul Potensi - #1719
Open
pandigresik wants to merge 1 commit into
Open
Conversation
Contributor
|
🔄 AI PR Review sedang antri di server...
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request: Bug pada Modul Potensi
Description
Memperbaiki bug pada Modul Potensi di frontend website, di mana halaman potensi menampilkan error "Requested filter(s)
tipe.slugare not allowed" karena filter tersebut belum terdaftar pada repository API. Selain itu, redirect link dari halaman index potensi mengarahkan ke URL yang salah (menggunakanslugyang tidak tersedia pada resource) sehingga tombol "Baca Selengkapnya" gagal menampilkan detail potensi.Changes made:
AllowedFilter::exact('tipe.slug')padaPotensiApiRepositoryagar filterfilter[tipe.slug]diterima oleh Spatie Query BuilderPotensiShowdari$slugmenjadi$iddiPageControllersesuai dengan perubahan URL dan cara pengambilan data resourcepotensi.kategori.showdari'/potensi/{kategori}/{slug}'menjadi'/potensi/{kategori}/{id}'agar sesuai dengan parameter id yang digunakan untuk mengambil dataindex.blade.phpdengan menggunakanitem.id(bukanpotensi.slug) sebagai parameter URLshow.blade.phpdarifilter[slug]menjadifilter[id]agar sesuai dengan cara resource potensi diambil berdasarkan idPageController(mis.: View,: JsonResponse,: RedirectResponse,string $slug)kirimKomentardankirimBalasandari inline$request->validate()ke class FormRequest terpisah (KirimKomentarRequest,KirimBalasanRequest)Reason for change:
filter[tipe.slug]di halaman index potensi ditolak oleh Spatie Query Builder karenatipe.slugbelum terdaftar diallowedFilters, sehingga halaman gagal memuat dataPotensiShow) mengambil data berdasarkanslugnamunslugtidak tersedia/benar pada resource, padahal API hanya mendukung pencarian viafilter[id]Impact of change:
✅ Bug Fix: Halaman index potensi dapat memuat dan menampilkan data sesuai filter tipe
✅ Bug Fix: Tombol "Baca Selengkapnya" mengarahkan ke URL yang benar dan halaman detail potensi menampilkan item yang sesuai
✅ Code Quality: Kontroller lebih rapi dengan type hint, dan validasi dipindah ke FormRequest terpusat
Related Issue
#1718
Steps to Reproduce
Before fix (problem):
[DOMAIN]/potensi/{kategori-slug})/potensi?filter[tipe.slug]=...&include=tipetipe.slugare not allowed. Allowed filter(s) are ..."After fix (solution):
[DOMAIN]/potensi/{kategori-slug})/potensi?filter[tipe.slug]=...&include=tipe/potensi/{kategori}/{id}→ detail ditampilkanidTesting on related features:
Checklist
Technical Details
Technical Explanation
Bug 1 — Filter ditolak:
Halaman index potensi mengirim request:
Spatie Query Builder menolak
filter[tipe.slug]karena key tersebut belum terdaftar padaallowedFiltersdiPotensiApiRepository. Solusinya menambahkan:Bug 2 — Parameter URL salah:
Resource potensi tidak memiliki atribut
slugyang digunakan oleh halaman index (potensi.slug). Link detail sebelumnya:Diperbaiki menjadi berbasis id:
Bug 3 — Pencarian detail:
show.blade.phpsebelumnya mengambil data denganfilter[slug]yang tidak valid. Karena data diambil berdasarkan item id dari list, query diubah menjadifilter[id].Refactor:
PotensiShow(string $kategori, string $id)— parameter diubah dari$slugke$idbersamaan dengan perubahan route{kategori}/{id}.PageControllerdiberi type hint parameter (string $slug) dan return type (View,JsonResponse,RedirectResponse).kirimKomentardankirimBalasandipindah dari$request->validate()inline keKirimKomentarRequestdanKirimBalasanRequest(aturan tetap identik).File changes detail
Baru:
app/Http/Requests/KirimKomentarRequest.php- FormRequest untuk validasi komentar artikelapp/Http/Requests/KirimBalasanRequest.php- FormRequest untuk validasi balasan komentarDiubah:
app/Repositories/PotensiApiRepository.php- TambahAllowedFilter::exact('tipe.slug')app/Http/Controllers/FrontEnd/PageController.php- Type hint + return type, potensi show parameter$slug→$id, pakai FormRequestroutes/web.php- Routepotensi.kategori.show{slug}→{id}themes/opendk/default/resources/views/pages/potensi/index.blade.php- Link detail menggunakanitem.idthemes/opendk/default/resources/views/pages/potensi/show.blade.php- Queryfilter[slug]→filter[id]Configuration changes
Tidak ada perubahan konfigurasi.
Dependencies added
No new dependencies
Testing
Manual Testing
Automated Testing
tipe.slugpada PotensiApiRepositoryPotensiShowdankirimKomentar/kirimBalasanScreenshots / Video
simplescreenrecorder-2026-09-01_14.06.04.mp4
Before:
tipe.slugare not allowed" pada halaman potensiAfter:
Breaking Changes
None
Migration Guide
Not required
References
Additional notes: Perubahan utama difokuskan pada perbaikan alur detail potensi (dari slug ke id) dan penambahan filter
tipe.slug. Refactor type hint dan FormRequest menyertai perubahan untuk meningkatkan kualitas kode. Disarankan untuk menambahkan test otomatis (unit/integration) pada PotensiApiRepository dan PageController sebagai follow-up.